clear

use "Drought_final.dta"


*Figure A4
reg demean_inc c.demean_prev_monsoon##c.demean_prev_monsoon, r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (Incumbent)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)


reg demean_pm c.demean_prev_monsoon##c.demean_prev_monsoon, r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (PM)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)


reg demean_cm c.demean_prev_monsoon##c.demean_prev_monsoon, r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (CM)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)


*Figure A5
reg demean_inc_pm c.demean_prev_monsoon##c.demean_prev_monsoon, r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (PM−Incumbent)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)



reg demean_inc_nonpm c.demean_prev_monsoon##c.demean_prev_monsoon, r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (Non-PM−Incumbent)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)


reg demean_inc_cm c.demean_prev_monsoon##c.demean_prev_monsoon, r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (CM−Incumbent)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)



reg demean_inc_noncm c.demean_prev_monsoon##c.demean_prev_monsoon , r cluster(id) 
margins, dydx(demean_prev_monsoon) at(demean_prev_monsoon = (-1(0.1)1))
marginsplot, title(Marginal Effects of Prev. Monsoon) legend(cols(2)) xtitle("Prev. Monsoon") ytitle("Marginal Effects on Vote Share (Non-CM−Incumbent)") graphregion(color(white)) xlabel(-1(0.5)1) ylabel(-6(1)6) level(90)



*Figure A28-29
foreach k in yresid_inc yresid_pm yresid_cm yresid_inc_pm yresid_inc_split2 yresid_inc_split yresid_inc_cm {
twoway (scatter `k' xresid, color(gs12)) ///
(lowess `k' xresid, color(gs7)) if xresid<=1 & xresid>=-1 & xresid!=., ///
ytitle(Residual (Vote Share)) legend(cols(2)) xtitle(Residual (Prev. Monsoon)) graphregion(color(white)) legend(off) xlab(-1(0.5)1)  ylab(-60(10)80) 
graph export "loess_`k'.png", replace
}


*Figure A30

foreach k in yresid_turn {
twoway (scatter `k' xresid, color(gs12)) ///
(lowess `k' xresid, color(gs7)) if xresid<=1 & xresid>=-1 & xresid!=., ///
ytitle(Residual (Turnout)) legend(cols(2)) xtitle(Residual (Prev. Monsoon)) graphregion(color(white)) legend(off) xlab(-1(0.5)1)  ylab(-60(10)80) 
graph export "loess_`k'.png", replace
}
